package uiLayer.util;

import javax.swing.JPanel;

import java.awt.BorderLayout;

import javax.swing.JButton;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.border.EmptyBorder;

public abstract class EditViewTemplate extends JPanel {
	private static final long serialVersionUID = 1L;
	
	private JPanel buttonPanel;
	private JPanel centerPanel;
	private JButton btnReset;

	
	/**
	 * Create the panel.
	 */
	public EditViewTemplate() {
		setLayout(new BorderLayout(0, 0));
		
		buttonPanel = new JPanel();
		buttonPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
		flowLayout.setAlignment(FlowLayout.TRAILING);
		add(buttonPanel, BorderLayout.SOUTH);
		
		btnReset = new JButton("");
		btnReset.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				handleReset();
			}
		});
		buttonPanel.add(btnReset);
		
		JButton btnSave = new JButton("Gem");
		btnSave.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				handleSave();
			}
		});
		buttonPanel.add(btnSave);
		
		centerPanel = new JPanel();
		add(centerPanel, BorderLayout.CENTER);
		centerPanel.setLayout(new BorderLayout(0, 0));

	}


	protected void handleReset() {
		doReset();
	}

	protected abstract void doReset();
	
	protected void handleSave() {
		doSave();
	}

	protected abstract void doSave();
	
	/**
	 * @return the buttonPanel
	 */
	protected JPanel getButtonPanel() {
		return buttonPanel;
	}

	/**
	 * @param buttonPanel the buttonPanel to set
	 */
	protected void setButtonPanel(JPanel buttonPanel) {
		this.buttonPanel = buttonPanel;
	}

	/**
	 * @return the centerPanel
	 */
	protected JPanel getCenterPanel() {
		return centerPanel;
	}

	/**
	 * @param centerPanel the centerPanel to set
	 */
	protected void setCenterPanel(JPanel centerPanel) {
		this.centerPanel = centerPanel;
	}

	/**
	 * @return the btnReset
	 */
	protected JButton getBtnReset() {
		return btnReset;
	}
	
}
